package com.ahzx.aboutus.controller;

import com.ahzx.aboutus.domain.AboutUs;
import com.ahzx.aboutus.service.AboutUsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 关于我们控制层
 *
 * @Author syg
 * @Date 2021/4/27 10:07
 * @Desc To be or not to be,that is a question.
 */
@RestController
@RequestMapping("/aboutUs")
public class AboutUsController extends BaseController {

    @Autowired
    private AboutUsService aboutUsService;

    @GetMapping
    public TableDataInfo list() {
        startPage();
        List<AboutUs> list = aboutUsService.selectAboutUsInfo();
        return getDataTable(list);
    }

    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Integer id) {
        return AjaxResult.success();
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody AboutUs aboutUs) {
        aboutUsService.insertAboutUs(aboutUs);
        return AjaxResult.success();
    }

    @PostMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id) {
        aboutUsService.deleteAboutUsByKey(id);
        return AjaxResult.success();
    }

    @PostMapping("/update")
    public AjaxResult update(@RequestBody AboutUs aboutUs) {
        aboutUsService.updateAboutUsById(aboutUs);
        return AjaxResult.success();
    }


}
